import time

GB = 1024**3
chunk = b'\0' * (64 * 1024 * 1024)  # 64MB chunk

start = time.time()
with open('E:/1gb_file.bin', 'wb') as f:
    for _ in range(GB // len(chunk)):
        f.write(chunk)
    # 写入剩余部分（如果 GB 不是 chunk 的整数倍）
    remainder = GB % len(chunk)
    if remainder:
        f.write(b'\0' * remainder)
elapsed = time.time() - start
print(f"写入1GB耗时: {elapsed:.2f} 秒")